Repository navigation
Fix #836: correct _const_node_type_names fallback for Python 3.14+ - #837
EhteshamSid wants to merge 1 commit into
Conversation
Fork of upstream 1.14.0 with the datacosmos integration: PEP 695 type parameters, full signature tokens, f-string delimiter fixes and the adopted upstream PRs python-rope#808, python-rope#837, python-rope#858, python-rope#865, python-rope#867, python-rope#868, python-rope#874, python-rope#880. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Before merging this, we need to clarify the contract of get_const_subtype_name(). Its docstring says "Get pre-3.8 ast node name", and get_node_type_name() delegates to it for Constant nodes. Returning "Constant" for every value on Python 3.14 therefore changes the helper's semantics; the removal of a private stdlib mapping does not by itself establish that this is the right replacement. My preference is to preserve the historical subtype names across supported Python versions unless a caller demonstrably needs a different result. Could you add a regression showing the user-visible failure on Python 3.14 and trace which consumer requires the changed names? Please also cover all supported constant value types. If the helper's contract genuinely needs to change, we should make that explicit and update its documentation and consumers together. |
|
Could you trace which Rope consumer requires |
|
The rope.base.ast module is not a public facing API. It's not a documented API and there's zero reasons consumers should be reaching to this level. These functions were added to help with smoothing over the Python 3.8 ast changes in patchedasttest.py and that's the only place it has ever been used in the rope codebase. Now that Python 3.8 is well out of support, this is just dead weight that can be removed as far as I'm concerned. If someone did actually call into this API, it's simple enough for them to back port it themselves to their own codebase. |
|
The import failure reported in #836 was already fixed by a083c5d and released in Rope 1.14.0. The report concerned Rope 1.13.0; #836 has since been closed as a duplicate of #810. I also checked this PR's head, b0430d7, on Python 3.14.8. The proposed mapping change breaks 69 patched-AST tests because their checker still expects historical names such as Running
The different test totals reflect the older PR branch. These runs used Python 3.14.8 with the installed pure-Python dependencies made available on its import path. I agree with @lieryan that these helpers do not need to be preserved as a public compatibility contract. My earlier emphasis on preserving that contract was misplaced. However, removing the obsolete helpers should update the test checker and assertions at the same time, consistently across supported Python versions, rather than changing the names only on Python 3.14 and leaving the callers unchanged. Since the reported import failure is already fixed, I suggest closing this PR as superseded and handling removal of the compatibility helpers as a separate cleanup. |
mcepl
left a comment
There was a problem hiding this comment.
I would just close this PR per my last comment
Fixes #836.
ast._const_node_type_nameswas removed in Python 3.14. Theexcept ImportErrorfallback inrope/base/ast.pyalready handled this case at the assertion level, but the fallback dict still used the old pre-3.8 names ("Num","Str","NameConstant", etc.). On Python 3.14 all constant literals areast.Constantnodes, so the fallback dict should map every type to"Constant"instead.Split the except block into two branches:
>= (3, 8)(i.e. Python 3.14+ which removed the attribute) uses"Constant"for all types;< (3, 8)keeps the original mapping for the old node types. Also removed the bareassertsince the if/else now makes the intent explicit.Added
ConstNodeTypeNamesTestto cover the expected return values ofget_const_subtype_name()per Python version.